<template>
  <div>
    <el-dialog
      title="新建工单"
      :visible.sync="dialogVisible"
      width="50%"
      center
    >
      <template>
        <el-form>
          <el-form-item label="问题描述：" :rules="[{ required: true }]">
            <el-input
              type="textarea"
              placeholder="为了更好的帮您解决问题，请详细描述问题及发生的位置"
              v-model="textarea"
              :autosize="{ minRows: 5, maxRows: 7 }"
              maxlength="200"
              show-word-limit
            >
            </el-input>
          </el-form-item>
          <el-form-item label="上传附件："><input type="file" /></el-form-item>
        </el-form>
      </template>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleConfirmClick">确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //dialog
      dialogVisible: false,
      textarea: "",
      desc: { required: true },
    };
  },
  props:{
  defaultInfo:{
      type:Object,
      defaule:()=>{}
  }
  },
  //监听defaultInfo的改变赋值
  watch: {
      defaultInfo(newValue){
            // console.log(newValue,oldValue);
            this.textarea = newValue.problem
      }
  },

  components: {},

  methods: {
      //点击确定按钮的逻辑
      handleConfirmClick(){
          //11章 coderwhy 07
          this.dialogVisible = false
          if (Object.keys(this.defaultInfo).length) {
              console.log('编辑用户',Object.values(this.defaultInfo));
              //获取的后写入的值 传入
              this.defaultInfo.problem =this.textarea
             console.log(this.defaultInfo);
          } else {
              console.log('新建用户');
          }
      }
  },
};
</script>

<style lang='scss' scoped>
</style>